package com.zygh.lz.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zygh.lz.entity.Xlevelservice;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public interface XlevelserviceMapper extends BaseMapper<Xlevelservice> {
    int deleteByPrimaryKey(Integer id);


    int insertSelective(Xlevelservice record);

    Xlevelservice selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Xlevelservice record);

    int updateByPrimaryKey(Xlevelservice record);

    //等级勤务所有应到人数
    int selectorderlyAll(@Param("sectionName") String sectionName,
                         @Param("ondutytime") String ondutytime);

    //一级勤务按大队应到人数
    List<HashMap> selectorderlyoneyd(String sectionName);

    Integer selectyjyd(String sectionName);

    //二级勤务按大队应到人数
    List<HashMap> selectorderlytweyd(String sectionName);

    Integer selectejyd(String sectionName);

    //三级勤务按大队应到人数
    List<HashMap> selectorderlythreeyd(String sectionName);

    Integer selectsjyd(String sectionName);

    //按等级大队查询区域
    List<Xlevelservice> selectxleveBydj(@Param("hierarchy") Integer hierarchy,
                                        @Param("sectionName") String sectionName);

    List<Xlevelservice> selectXleveAll();


    //按等级按大队展示大队
    List<HashMap> selectXlevedJ(@Param("hierarchy") Integer hierarchy,
                                @Param("battalion") String battalion);

    //按等级按大队展示详情
    List<Xlevelservice> selectXleverdJnum(@Param("hierarchy") Integer hierarchy,
                                          @Param("sectionName") String sectionName);

    //查询特殊勤务左侧列表
    List<Xlevelservice> selectSpecialService(@Param("lx") Integer lx,
                                             @Param("sectionId") String sectionId,
                                             @Param("hierarchy") String hierarchy);

    //查询特殊勤务左侧列表
    List<Xlevelservice> selectSpecialServices(@Param("state") Integer state);

    int delSpecialService(@Param("id") Integer id);

    List<Xlevelservice> selectXlevelservice(Integer type);

    List<HashMap> findtype(@Param("sectionId") Integer sectionId,
                           @Param("state") Integer state);

    List<Map> findXleceByType(String state);

    //根据等级和特殊勤务类型查询任务
    List<Xlevelservice> findXlevelserviceByState(@Param("hierarchy") String hierarchy,
                                                 @Param("state") Integer state);


    /**
     * =========================================================================================
     */

    //特殊勤务根据岗位和部门查询应到人数
    int findDueNumber(@Param("sectionId") Integer sectionId,
                      @Param("state") Integer state);

    //特殊勤务根据岗位和部门查询当前签到人数
    int findSignNumber(@Param("sectionId") Integer sectionId,
                       @Param("state") Integer state,
                       @Param("type") String type);


    /**
     * =====================================特殊勤务右侧详情栏信息===============================================
     */

    //岗位数
    int findStationNum(@Param("state") int state,
                       @Param("hierarchy") Integer hierarchy);

    //部署警力
    int finddePloyPtrength(@Param("state") int state,
                           @Param("hierarchy") Integer hierarchy);

    /**
     * 详情
     *
     * @param state     类型
     * @param hierarchy 等级
     * @return
     */
    List<Map> findSpecialDetail(@Param("state") Integer state,
                                @Param("hierarchy") Integer hierarchy,
                                @Param("sectionId") Integer sectionId);


    //部署警力数
    int findDetailNum(@Param("state") Integer state,
                      @Param("hierarchy") Integer hierarchy,
                      @Param("sectionId") Integer sectionId);

    //部署警力
    List<Map> findDetailPtrength(@Param("state") Integer state,
                                 @Param("hierarchy") Integer hierarchy,
                                 @Param("sectionId") Integer sectionId);


    //当班在线岗位
    List<Map<String, Object>> findOnLineSecret(@Param("positionId") String positionId,
                                               @Param("battalion") String battalion);

    //当班在线警员
    List<Map> findOnLinePtrength(@Param("state") String state,
                                 @Param("assignmentid") Integer assignmentid,
                                 @Param("battalion") String battalion);


    /**
     * =================================section_Did=================================================
     */
    //一级
    List<Map<String,Object>> findStairDuty();

    //二级
    List<Map<String, Object>> findSecondDuty(String state);

    //三级
    List<Map<String, Object>> findThreeDuty(@Param("state") String state,
                                            @Param("hierarchyid") String hierarchyid);

    //根据岗位id查询类型名称
    String findDutynameById(String id);

    List<Map<String,Object>> findLastDuty(String positionId);

    List<Map<String, Object>> findOnLinePtrengthPid(@Param("positionId") String station,
                                    @Param("battalion") String battalion);
@Select(" select id,callsign,place,number from xlevelservice where zt = 1 and position_id = #{id}")
    List<Map> sptypeDetail(Integer id);
}